package com.example.myblog.service.user;

import com.example.myblog.domain.Article;
import com.example.myblog.mapper.UserMapper;
import com.example.myblog.domain.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Optional;

/**
 * @Author: Wu YunXia
 * @Description: 用户
 * @Date: Created in 10:14 2020/11/26
 * @Modefied By:
 */
@Service
public class UserServiceImpl{
    @Resource
    UserMapper userMapper;

    /**
     * 编辑辨识
     */
    public User queryIdByUuid(String uuid){
        return userMapper.queryIdByUuid(uuid);
    }

    /**
     * 添加
     */
    public int addUser(User user){
        return userMapper.addUser(user);
    }

    /**
     * 更新
     */
    public int updateUser(User user){
        return userMapper.updateUser(user);
    }

    /**
     * 获取全部
     */
    public List<User> getUserAll(){
        return userMapper.getUserAll();
    }

    /**
     * 删除
     */
    public int delUser(int id){
        return userMapper.delUser(id);
    }

    /**
     * 获取单个
     */
    public User selectById(int id){
        return userMapper.selectById(id);
    }


    /**
    * @desc: 注册
    */
    public int register(User user){
        return userMapper.register(user);
    }


    /**
    * @desc: 改变state  激活邮件
    */
    public int activeEmail(String uuid){
        return userMapper.activeEmail(uuid);
    }


    /**
    * @desc: 登录
    */
    public List<User> login(String username){
        return userMapper.login(username);
    }


    /**
     * @desc: 按id查询
     */
    public List<User> queryId(int id){
        return userMapper.queryId(id);
    }


    /**
    * @desc: 按邮箱查询
    */
    public List<User> queryForEmail(String email){
        return userMapper.queryForEmail(email);
    }


    /**
    * @desc: 按用户名查询
    */
    public List<User> queryForUsername(String username){
        return userMapper.queryForUsername(username);
    }



    /**
     * @desc: 按uuid查询
     */
    public List<User> queryForUuid(String uuid){
        return userMapper.queryForUuid(uuid);
    }



    /**
     * @Date 2020/11/29
     * @desc: 重置密码
     */
    public int resetPass(String email,String random,String uuid){
        return userMapper.resetPass(email,random,uuid);
    }
    
    
    /**
    * @Date 9:34 2020/11/30
    * @desc: 修改密码
    */
    public int updatePass(int id,String password,String uuid){
        return userMapper.updatePass(id,password,uuid);
    }



    public List<User> queryAll(){
       return userMapper.queryAll();
    }
}
